package com.neuedu.springmvc.controller;

import com.neuedu.springmvc.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 项目：springmvc-java4
 * 创建时间：  2022-03-24   11:08
 * 作者 :jshand
 * 描述 :
 */
@Controller
public class UserListController {

    @RequestMapping("userList")
    public String userList(Model model ,

  @ModelAttribute User user){


        //根据信息user 获取用户集合,模拟从数据中查询数据
        List list = new ArrayList();
        for (int i = 0; i < 10; i++) {
            Map map = new HashMap();
            map.put("id",i);
            map.put("username","username:"+i);
            list.add(map);
        }
        model.addAttribute("list",list);
        //model.addAttribute("user",user);

        return "forward:/list.jsp";
    }

}
